package cn.com.sueframe.vo;

import java.util.Date;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

/**
 * 自定义的所有VO的父类
 * 
 * @author anmin Create Oct 6, 2012
 * 
 */
public class BaseVO {
	/******************** 数据库常用字段***************/
	
	/**
	 * 主键id
	 */
	public String id;
	
	/**
	 * 记录创建者
	 */
	public String createdBy;
	
	/**
	 * 记录创建日期
	 */
	public Date creationDate;
	
	/**
	 * 记录修改者
	 */
	public String lastUpdatedBy;
	
	/**
	 * 记录修改日期
	 */
	public Date lastUpdationDate;
	/**
	 * 备注
	 */
	public String remark;
	
	/**
	 * 记录激活标志，0表示记录无效，1表示记录有效
	 */
	public String activeFlag; 
	
	/*********************** 中英切换标识*******************/
	
	/**
	 *  国家语言信息
	 */
	private String language = "CN";
	
	/***************分页信息*********************/
	
	/**
	 * 分页对象
	 */
	private PageVO pageVO;// 分页对象
	
	/***************用户信息*********************/
	
	/**
	 * 用户名
	 */
	private String userName;
	
	/**
	 * 用密码
	 */
	private String userPassword;
	
	/**
	 * 用编号
	 */
	private String userNo;

	public BaseVO() {
		initLanguage();
		initCurUserInfo();
	}

	/**
	 * 初始化语言信息
	 * 
	 * @author anmin Create 2013-4-2
	 */
	private void initLanguage() {
		HttpServletRequest servletRequest = ServletActionContext.getRequest();
		HttpSession session = servletRequest.getSession();
		Object languageObj = session.getAttribute("ceswich");
		if (languageObj != null) {
			language = languageObj + "";
			if ("zh_CN".equals(this.language)) {
				language = "CN";
			}
		}
	}

	/**
	 * 初始化当前用户信息
	 * @author anmin
	 * @return void Created May 28, 2013
	 */
	private void initCurUserInfo() {
		HttpServletRequest servletRequest = ServletActionContext.getRequest();
		HttpSession session = servletRequest.getSession();
		userName = session.getAttribute("userName") + "";
		userPassword = session.getAttribute("userPassword") + "";
		
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getCreatedBy() {
		return createdBy;
	}

	public void setCreatedBy(String createdBy) {
		this.createdBy = createdBy;
	}

	public Date getCreationDate() {
		return creationDate;
	}

	public void setCreationDate(Date creationDate) {
		this.creationDate = creationDate;
	}

	public String getLastUpdatedBy() {
		return lastUpdatedBy;
	}

	public void setLastUpdatedBy(String lastUpdatedBy) {
		this.lastUpdatedBy = lastUpdatedBy;
	}

	public Date getLastUpdationDate() {
		return lastUpdationDate;
	}

	public void setLastUpdationDate(Date lastUpdationDate) {
		this.lastUpdationDate = lastUpdationDate;
	}

	public String getActiveFlag() {
		return activeFlag;
	}

	public void setActiveFlag(String activeFlag) {
		this.activeFlag = activeFlag;
	}

	public String getLanguage() {
		return language;
	}

	public void setLanguage(String language) {
		this.language = language;
	}

	public PageVO getPageVO() {
		return pageVO;
	}

	public void setPageVO(PageVO pageVO) {
		this.pageVO = pageVO;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getUserPassword() {
		return userPassword;
	}

	public void setUserPassword(String userPassword) {
		this.userPassword = userPassword;
	}

	public String getUserNo() {
		return userNo;
	}

	public void setUserNo(String userNo) {
		this.userNo = userNo;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

}
